package com.ms.education.course.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ms.education.course.entity.Comment;
import com.ms.education.course.mapper.CommentMapper;
import com.ms.education.course.service.CommentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 课程评论 服务实现类
 * </p>
 *
 * @author ms
 * @since 2023-01-17
 */
@Service
public class CommentServiceImp extends ServiceImpl<CommentMapper, Comment> implements CommentService {

    @Override
    public Page<Comment> pageComment(long current, long limit, Integer courseId) {
        Page<Comment> page = new Page<>();
        page.setCurrent(current).setSize(limit);
        QueryWrapper<Comment> wrapper = new QueryWrapper<Comment>().eq("course_id", courseId).orderByDesc("gmt_create");
        page(page, wrapper);
        return page;
    }
}
